<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>编辑经营日报-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<link rel="stylesheet" href="__PUBLIC__/mobile/css/dropload.css">
</head>
<body style="background: #f3f3f3;">
<form method="post" name="number_validate" id="password_validate" novalidate="novalidate">
<div class="header">
	<a class="close_btn" href="__APP__/Mobile/Project/project_data_list/id/{$pid}/year_month/{$year_month}"></a>编辑经营日报<button type="button" class="send_btn send_show animate">提交</button>
</div>
<div class="content">
    <div class="operate_label">
		<div class="cont all">
			<input type="hidden" name="action" value="add">
			<input type="hidden" name="date" value="{$date}">
			<input type="hidden" name="pid" value="{$pid}">
			<input type="hidden" name="year_month" value="{$year_month}">
            <div class="title">
				<p>日期：{$date}</p>
            </div>
            <div class="label_box">
				<foreach name="jysj" item="vo" key="k">
                    <foreach name="vo['second']" item="wo"  key="kk">
                            <foreach name="wo['third']" item="xo" key="kkk">
								<if condition="$wo['id'] eq 254">
									<a href="javascript:;" sid="{$wo['id']}" tid="{$xo['id']}" data-id="{$xo['num']}" <if condition="$xo['ch'] eq 0">class="two"<elseif condition="$xo['ch'] eq 1"/><if condition="$xo['sk'] eq 'sk'">class="two sk"<else/>class="two td"</if><elseif condition="$xo['ch'] eq 2"/>class="two sk td active"</if>>{$xo['third_name']}</a>
								<else/>
									<a href="javascript:;" sid="{$wo['id']}" tid="{$xo['id']}" data-id="{$xo['num']}" <if condition="$xo['choose'] eq 1">class="active"</if>>{$xo['third_name']}</a>
								</if>
                            </foreach>
                    </foreach>
                </foreach>
            </div>
        </div>
        <div <if condition="$jysj_detail neq NULL">class="hb_list"<else/>class="hb_list hide"</if>>
            <table>
				<foreach name="jysj_detail" item="vo">
					<tr>
						<td><if condition="$vo['third_name'] eq NULL">{$vo['second_name']}<else/>{$vo['third_name']}</if><if condition="$vo['people'] neq NULL">-{$vo['people']}</if></td>
						<td><if condition="$vo['number'] neq NULL">{$vo['number']}人</if></td><td>{$vo['money']}元</td>
						<td width="30px" class="text_c">
							<a class="icon_delete_btn" href="javascript:;"></a>
							<input class="size_input2" type="hidden" value="{$vo['size']}" <if condition="$vo['people'] eq '散客'">hdclass="sk"<elseif condition="$vo['people'] eq '团队'"/>hdclass="td"</if>>
							<input type="hidden" value="{$vo['number']}" name="numbers[]">
							<input type="hidden" value="{$vo['money']}" name="moneys[]">
							<input type="hidden" value="{$vo['people']}" name="peoples[]">
							<input type="hidden" value="{$vo['sid']}" name="sid[]">
							<input type="hidden" value="{$vo['tid']}" name="tid[]">
						</td>
					</tr>
				</foreach>
            </table>
        </div>
    </div>
</div>
</form>
<!-- 弹出框 -->
<div class="Alert operate_alert">
    <div>
        <p class="operate_label_name"><span class="span"></span></p>
        <div class="item_menu hide animate"><a class="item_td" href="javascript:;" data-class="td">团队</a><a class="item_sk" href="javascript:;" data-class="sk">散客</a><span>必选分类</span></div>
        <table class="innput_list">
            <tr class="peptr hide">
                <td>人数</td>
                <td style="padding-right:10px" class="text_r"><input type="number" name="people"></td>
                <td>人</td>
            </tr>
            <tr>
                <td>金额</td>
                <td style="padding-right:10px" class="text_r"><input type="number" name="money"></td>
                <td>元</td>
            </tr>
        </table>
        <div class="btn_box clearboth">
            <a class="btn_close float_l" href="javascript:;">取消</a><button class="btn_alert float_r disabled" disabled>确定</button>
        </div>
        <input class="size_input" type="hidden" sid="" tid="">
    </div>
</div>
<include file="Include:javascript" />
<script src="__PUBLIC__/mobile/js/dropload.min.js"></script>
<script>
    $(function(){
        if($('.hb_list tr').length>0){
            $('.header .send_btn').addClass('active');
        }
        $('.send_btn').click(function(){localStorage.clear();});
        var winh = $(window).height();
        $('.operate_label').css('min-height',winh-44);
        //标签点击
        $('.label_box a').click(function(){
            var data = $(this).attr('data-id'),
                sid = $(this).attr('sid'),
                tid = $(this).attr('tid');

            Mask();
            $('.Alert').fadeIn().find('textarea').focus();
            var text = $(this).text();
            $('.operate_label_name span').html(text);
            $('.size_input').val(data);
            $('.size_input').attr('sid',sid);
            $('.size_input').attr('tid',tid);
            if($(this).hasClass('two')){
                $('.item_menu').removeClass('hide');
                $('.innput_list .peptr').removeClass('hide');
            }else{
                $(this).addClass('active');
            }
            if($(this).hasClass('td')){
                $('.item_td').addClass('hide');
            }
            if($(this).hasClass('sk')){
                $('.item_sk').addClass('hide');
            }
        })
        $('.item_menu a').click(function(){
            $(this).addClass('active').siblings().removeClass('active');
        })
        //弹框必填判断
        $('.item_menu a').click(function(){
            $(this).addClass('active').siblings().removeClass('active');
            var pval = $("[name='people']").val(),
                mval = $("[name=''money]").val();
            if($('.item_menu').hasClass('hide')){
                if(mval==''){
                    $(".btn_alert").addClass("disabled").attr('disabled',true);
                }else{
                    if(mval!='' && /(^0\.\d{1,2}$)|(^[1-9][0-9]*(\.\d{1,2})?$)/.test(mval)){
                        $(".btn_alert").removeClass("disabled").attr('disabled',false);
                    }else{
                        $(".btn_alert").addClass("disabled").attr('disabled',true);
                    }
                }
            }else{
                if($('.item_menu .active').length<1){
                    $(".btn_alert").addClass("disabled").attr('disabled',true);
                }else{
                    if(pval!='' && /^\+?[1-9]\d*$/.test(pval)){
                        if(mval!='' && /(^0\.\d{1,2}$)|(^[1-9][0-9]*(\.\d{1,2})?$)/.test(mval)){
                            $(".btn_alert").removeClass("disabled").attr('disabled',false);
                        }else{
                            $(".btn_alert").addClass("disabled").attr('disabled',true);
                        }
                    }else{
                        $(".btn_alert").addClass("disabled").attr('disabled',true);
                    }
                }
            }
        })
        $(".innput_list input").bind('input propertychange', function() {
            var pval = $("[name='people']").val(),
                mval = $("[name=''money]").val();
            if($('.item_menu').hasClass('hide')){
                if(mval==''){
                    $(".btn_alert").addClass("disabled").attr('disabled',true);
                }else{
                    if(mval!='' && /(^0\.\d{1,2}$)|(^[1-9][0-9]*(\.\d{1,2})?$)/.test(mval)){
                        $(".btn_alert").removeClass("disabled").attr('disabled',false);
                    }else{
                        $(".btn_alert").addClass("disabled").attr('disabled',true);
                    }
                }
            }else{
                if($('.item_menu .active').length<1){
                    $(".btn_alert").addClass("disabled").attr('disabled',true);
                }else{
                    if(pval!='' && /^\+?[1-9]\d*$/.test(pval)){
                        if(mval!='' && /(^0\.\d{1,2}$)|(^[1-9][0-9]*(\.\d{1,2})?$)/.test(mval)){
                            $(".btn_alert").removeClass("disabled").attr('disabled',false);
                        }else{
                            $(".btn_alert").addClass("disabled").attr('disabled',true);
                        }
                    }else{
                        $(".btn_alert").addClass("disabled").attr('disabled',true);
                    }
                }
            }
        })
        //弹框取消
        $('.btn_close').click(function(){
            var size = $('.size_input').val();
            $(this).parents('.operate_alert').find('input').val('');
            $('.item_menu a').removeClass('active');
            $('.label_box a').eq(size).removeClass('active');
            $(".btn_alert").addClass("disabled").attr('disabled',true);
            $('.item_menu').addClass('hide');
            $('.innput_list .peptr').addClass('hide');
            $('.item_menu a').removeClass('hide');
        })
        //弹框确定
        $('.btn_alert').click(function(){
            var _this = $(this),
                txt = _this.parents('.operate_alert').find('.span').text(),
                txt2 = _this.parents('.operate_alert').find('.item_menu').find('.active').text(),
                pval = $("[name='people']").val(),
                mval = $("[name=''money]").val(),
                size = $('.size_input').val(),
                sid = $('.size_input').attr('sid'),
                tid = $('.size_input').attr('tid'),
                dclass= $('.item_menu .active').attr('data-class'),
                html = '';
            
            html += '<tr><td>'+txt+'';
            if($('.item_menu').hasClass('hide')){
                
            }else{
                html += '-';
            }
            html += ''+txt2+'</td><td>';
            if($('.peptr').hasClass('hide')){
                
            }else{
                html += ''+pval+'人';
            }
            html += '</td><td>'+mval+'元</td><td width="30px" class="text_c"><a class="icon_delete_btn" href="javascript:;"></a><input class="size_input2" type="hidden" value="'+size+'" hdclass="'+dclass+'"><input type="hidden" value="'+pval+'" name="numbers[]"><input type="hidden" value="'+mval+'" name="moneys[]"><input type="hidden" value="'+txt2+'" name="peoples[]"><input type="hidden" value="'+sid+'" name="sid[]"><input type="hidden" value="'+tid+'" name="tid[]"></td></tr>';
            $(this).parents('.operate_alert').find('input').val('');
            $('.item_menu a').removeClass('active');
            _this.parents('.Alert').fadeOut();
            $('.Mask').fadeOut(function(){
                $(this).remove();
            });
            $('.hb_list').removeClass('hide').find('table').append(html);
            if($('.hb_list tr').length>0){
                $('.header .send_btn').addClass('active');
            }
            $(".btn_alert").addClass("disabled").attr('disabled',true);
            $('.label_box a').eq(size).addClass(''+dclass+'');
            $('.item_menu').addClass('hide');
            $('.innput_list .peptr').addClass('hide');
            if($('.item_menu .hide').length>0){
                $('.label_box a').eq(size).addClass('active');
            }
            $('.item_menu a').removeClass('hide');
        })
        //删除
        $("body").on('click','.icon_delete_btn',function(){
            modal_alert('您确定要删除吗？');
            $(this).parents('tr').addClass('tr_det');
        })
        $('body').on('click','.modal_sub',function(){
            $(this).parents('.modal_alert').fadeOut(function(){
                $(this).remove();
            });
            $('.Mask').fadeOut(function(){
                $(this).remove();
            });
            var size = $('.tr_det').find('.size_input2').val(),
                hdclass = $('.tr_det').find('.size_input2').attr('hdclass');
            $('.tr_det').remove();
            $('.label_box a').eq(size).removeClass('active');
            $('.label_box a').eq(size).removeClass(''+hdclass+'');
            if($('.hb_list tr').length<1){
                $('.header .send_btn').removeClass('active');
                $('.hb_list').addClass('hide');
            }
        });
        $("body").on('click','.modal_close',function(){
            $('.hb_list').find('tr').removeClass('tr_det');
        })
        //提交
        $('.send_btn').click(function(){
            $.ajax({
                type: 'POST',
                async:false,
				dataType:"json",
                data:$("[name='number_validate']").serialize(),
                url:"__APP__/Mobile/Project/project_data_list_ajax",
                dataType: 'json',
                success: function(data){
                    location.href="__APP__/Mobile/Project/project_data_list/id/"+data.pid+"/year_month/"+data.year_month;
                }
            })
        })
    })
</script>
</body>
</html>
